package com.jsmy.softapp.presenter;


import com.jsmy.softapp.model.BaseModel;

import java.lang.ref.WeakReference;

/**
 * Created with Android Studio.
 * User: wei_cd.
 * Date: 2018/3/12.
 * Time: 12:03.
 * To change for file | settings | file and code templates.
 */

public abstract class BasePresenter<V> implements BaseModel.OnLoadCompleteListener{

    protected WeakReference<V> reference;

    public void attachView(V view){
        reference = new WeakReference<V>(view);
    }

    public void detachView(){
        if (reference != null){
            reference.clear();
            reference = null;
        }
    }

    protected V getView(){
        return reference.get();
    }

}
